﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hyt.Web.Security;
using Hyt.Passport;
using Hyt.Passport.Service;
using Hyt.Web;
using Hyt.Passport.Models;

namespace Huayuan.ApplicationService
{
    public partial class ServiceCenter
    {
        public virtual void CreateDepartment(string name,string parentcode=null)
        {
            var departmentService = UnitOfWork.Get<DepartmentService>();
            departmentService.CreateByParent(name, parentcode);
        }

        public virtual List<Department> GetAllDepartment()
        {
            var departmentService = UnitOfWork.Get<DepartmentService>();
            return departmentService.GetAll().ToList();
        }

        public virtual Department GetDepartmentById(Guid id)
        {

            var departmentService = UnitOfWork.Get<DepartmentService>();
            return departmentService.Get(id);
        }

        public virtual Department GetDepartmentByCode(string code)
        {

            var departmentService = UnitOfWork.Get<DepartmentService>();
            return departmentService.Get(code);
        }

        public virtual void ModifyDepartmentName(Department depart)
        {
            var departmentService = UnitOfWork.Get<DepartmentService>();
            departmentService.ModifyName(depart);
        }

        public virtual void DeleteDepartment(Guid id)
        {
            var departmentService = UnitOfWork.Get<DepartmentService>();
            departmentService.Remove(id);
        }
    }
}
